package tcu.iot.mqttupdate.entity;

import lombok.Data;

import java.io.Serializable;

@Data
public class R implements Serializable {
    /**
     JSON格式返回格式统一封装
     code：成功200，失败401
     success："true"，"false"
     message："成功"，"失败"
     data：object格式，可传入任意数据
     * */
    private int code;
    private String success;
    private String message;
    private Object data;

    public static R ok(String success, int code, String message, Object data) {
        R result = new R();
        result.setCode(code);
        result.setSuccess(success);
        result.setMessage(message);
        result.setData(data);
        return result;
    }

    public static R failed(String success, int code, String message) {
        R result = new R();
        result.setCode(code);
        result.setSuccess(success);
        result.setMessage(message);
        return result;
    }

}
